<!DOCTYPE html>
<html>

	<head>
		<!-- Standard Meta -->
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
		<!-- Site Properties -->
		<title>${databaseName}</title>
		<link href="https://cdn.bootcss.com/semantic-ui/2.3.0/semantic.min.css" rel="stylesheet">
		<script src="https://cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
		<script src="https://cdn.bootcss.com/semantic-ui/2.3.0/semantic.min.js"></script>
		<!-- Content JS HERE !-->
		<style>
			.last.container {
				margin-bottom: 300px !important;
			}
			
			h1.ui.center.header {
				margin-top: 3em;
			}
			
			h2.ui.center.header {
				margin: 4em 0em 2em;
			}
			
			h3.ui.center.header {
				margin-top: 2em;
				padding: 2em 0em;
			}
			.hide{
				display: none;
			}
		</style>
	</head>

	<body>
		<!-- 目录 -->
		<h1 id="top" class="ui center aligned header ">数据库名称：${databaseName}</h1>
		
		<div  class="ui text container last db-index">
			<h3 class="ui center aligned">目录</h3>
			
				<div class="ui segment">
					<div class="ui list divided ">
						<#list tableInfos as tableInfo>
						<div class="item">
							<div class="content">
								<a onclick="toTable(${tableInfo_index})">${tableInfo_index+1}. ${tableInfo.tableName}
									<#if tableInfo.tableRemark?default("")?trim?length gt 1>
									(${tableInfo.tableRemark})
									</#if>
								</a>
							</div>
						</div>
						
						</#list>
					</div>

				</div>
			
		</div>
		
		<!--/目录-->
		<!--表-->
		<#list tableInfos as tableInfo>
		<div id="db-table-${tableInfo_index}" style="display: none" class="ui container last db-table ">
			<h1 class="ui center aligned header">表名:${tableInfo.tableName}</h3>
			<h3 class="ui center aligned ">注释:${tableInfo.tableRemark}</h3>
			<h3 class="ui center aligned " ><a onclick="toIndex()">返回目录</a></h3>
			<table class="ui orange celled   table">
				<caption>表格信息</caption>
				<thead>
					<tr>
						<th>字段</th>
						<th>类型</th>
						<th>注释</th>
						<th>键</th>
						<th>能否为空</th>
						<th>默认值</th>
						<th>其他</th>
					</tr>
				</thead>
				<tbody>
					<#list tableInfo.fields as field>
					<tr>
						<td>${field.field}</td>
						<td>${field.type}</td>
						<td>${field.remark}</td>
						<td>${field.key}</td>
						<td>${field.nullAble}</td>
						<td>${field.defaultValue}</td>
						<td>${field.extra}</td>
					</tr>
					</#list>
				</tbody>

			</table>
			
			<table class="ui orange celled   table">
				<caption>索引信息</caption>
				<thead>
					<tr>
						<th>名称</th>
						<th>栏位</th>
						<th>索引类型</th>
						<th>索引方式</th>
						<th>索引备注</th>
					</tr>
				</thead>
				<tbody>
					<#list tableInfo.keys as key>
					<tr>
						<td>${key.name}</td>
						<td>${key.getColumnCombine()}</td>
						<td>
							<#if key.unique>
								UNIQUE
								<#else>
								NORMAL
							</#if>
						</td>
						<td>${key.indexType}</td>
						<td>${key.indexComment}</td>
					</tr>
					</#list>
				</tbody>

			</table>
		</div>
		</#list>
		<!-- /表 -->

		<script type="text/javascript">
			
			
			function toTable(id){
				$(".db-table").hide();
				$(".db-index").hide();
				$("#db-table-"+id).show();
				toTop();
			}
			
			function toIndex(){
				$(".db-table").hide();
				$(".db-index").show();
				toTop();
			}
			
			function toTop(){
				location.href = "#top";
			}
			
		</script>

	</body>

</html>